/*
 * @Author: your name
 * @Date: 2020-09-23 09:26:51
 * @LastEditTime: 2020-10-21 16:56:51
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /Project/index.js
 */
/* 引入express框架 */
const express = require('express');
const config = require('./config')
const routes = require('./routes'); //导入自定义路由文件，创建模块化路由

/* 引入body-parser */
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json()); // 解析json数据格式
app.use(bodyParser.urlencoded({extended: true})); // 解析form表单提交的数据application/x-www-form-urlencoded

app.use('/', routes);
/* 引入cors */
const cors = require('cors');
app.use(cors());

/* 引入mysql */
const mysql = require('mysql');
const { json } = require('body-parser');
const conn = mysql.createConnection(config)
conn.connect();
 
/* 监听端口 */
app.listen(8080, () => {
	console.log('服务已启动 http://localhost:8080');
})